package com.wanghengzhi.design.patterns.observer;

class ObserverMain {

    /**
     * 观察者模式: 当一个对象发生变化时，可以通知所有依赖的对象。
     * @param args
     */
    public static void main(String[] args) {
        Subject subject = new Subject();

        new HexaObserver(subject);
        new OctalObserver(subject);
        new BinaryObserver(subject);

        System.out.println("First state change: 15");
        subject.setState(15);
        System.out.println("Second state change: 10");
        subject.setState(10);
    }

}
